home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Life 1996 January
/
Computer Life January 1996.iso
/
telix
/
tfw.5
/
WINHOST.SLT
< prev
Wrap
Text File
|
1995-07-28
|
52KB
|
1,856 lines
//
// W I N H O S T . S L T
//
// Copyright (C) 1988-1995 deltaComm Development.
//
// - Written by Colin Sampaleanu.
// - Modifications by Jeff Woods, Feb '91, to add help function and support
// for locked modems.
// - Modifications by Dan Horn, Nov '92, fixed 'floating' timer bug.
// - Thanks to Jon Fleming for his help in porting this to Windows.
// - Modifications for hot keys and logins, fixes for chat mode and
// <=9600 baud remote dos shells in Dec '94 by Sean Palmer
// - Modifications to Connect baud parsing Jan '95 by Sean Palmer
// - Modifications to allow ANSI and RIP displays Feb '95 by Jeff Smith
// - Message system added March '95 by Jeff Smith
//
// This is a Host Mode for Telix, written as a script file.
// To configure Host Mode parameters such as passwords, run the 'WCONFIG'
// script. That script is run automatically if the Host Mode configuration
// file 'WINHOST.CNF' is missing.
//
// This script will only work with Hayes compatible modems, but may be
// modified for operation with other modems.
//
//////////////////////////////////////////////////////////////////////////////
#stack 1536 // Increased stack size
// Parameters which are configured from the WinHost configuration file
str host_downloads[64], // Default where users may download from
host_uploads[64], // Default where uploaded files go
host_message[64]; // Default used by message system
int direct_connect = 0, // 0 = using a modem
modem_lock = 0,
closed_sys = 0; // 0 = users may sign up on line if not
// found in the config file
// Various global variables
str current_caller[31], // storage of current caller's name
our_dir[64]; // Winhost directory (either Telix's
// scripts directory or the contents
// of the HOST2DIR environment variable
// if it exists)
int finished_caller, // set to TRUE when must return to top
local_mode, // set to TRUE when local test mode
access_level, // access level of current caller
carrier_counts = 1, // TRUE if should watch Carrier signal
already_connected = 0,
exit_requested = 0, // set to TRUE if Sysop has pressed Esc
connection_lost = 0, // set to TRUE when carrier lost
kill_user = 0, // set to TRUE when user must be purged
min_user_name = 5, // Minimum length of user's name
user_has_own_dir; // Flag to restrict the user to one dir
int old_scr_chk_key, // storage for some system variables
old_cisb_auto, // which we have to modify and put
old_zmod_auto, // back to what they were when done
old_sound,
RIP_On, ANSI_On; // Flag ANSI and RIP capability
str old_down_dir[64],
old_up_dir[64],
tfw_down_dir[64],
tfw_up_dir[64],
old_usage_fname[64];
int ndx_fil, mssg_num, // Message system variables
mssg_time, mssg_priv; // used by the index file
str mssg_to[30], mssg_from[30], // "message.ndx"
mssg_subj[30];
#INCLUDE "WHUTILS.SLT" // Functions which are shared with the
// configuration managements script
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
main() {
int c;
str s[80], filnam[64];
tfw_up_dir = _up_dir;
tfw_down_dir = _down_dir;
clear_scr;
get_our_dir;
if (read_host_config_file == -1) {
prints("Unable to read WINHOST.CNF...");
prints("Running WCONFIG, the Host Mode configuration script.^M^J");
s = our_dir;
strcat (s, "WCONFIG");
calld(s);
if (read_host_config_file() == -1) {
prints("Still unable to read WINHOST.CNF. Aborting Host Mode.^M^J");
return -1;
}
}
prints ("Checking existence of directories ...");
if (!(check_directory(host_downloads)
&& check_directory(host_uploads)
&& check_directory(host_message))) {
prints("Aborting Host Mode.");
return -1;
}
old_scr_chk_key = _scr_chk_key;
_scr_chk_key = 0;
old_cisb_auto = _cisb_auto;
_cisb_auto = 0;
old_zmod_auto = _zmod_auto;
_zmod_auto = 0;
old_sound = _sound_on;
_sound_on = 0;
old_down_dir = _down_dir;
old_usage_fname = _usage_fname;
s = our_dir;
strcat (s, "HOST2.LOG");
usagelog (s);
carrier_counts = !direct_connect;
already_connected = (carrier_counts && carrier());
filnam=host_message;
strcat(filnam, "message.ndx");
if (filefind(filnam, 0)) {
ndx_fil=fopen(filnam, "r+");
if (ndx_fil)
update_ndx_file(); // scan index file for msgs more than
// a certain age, & delete them
}
else { // Create the index file
ndx_fil=fopen(filnam, "w+");
mssg_from="Internal";
mssg_to="Internal";
mssg_priv=1;
mssg_time=curtime();
mssg_subj="Time Index";
ndx_write(0);
}
while (1) {
_down_dir = host_uploads; // these are reversed because we are the Host
old_up_dir = _up_dir;
_up_dir = host_downloads; // these are reversed because we are the Host
user_has_own_dir = 0;
if (!direct_connect && !already_connected) {
if (!modem_lock)
set_cparams(modem_lock, 0, 8, 1);
delay_scr(3);
prints("Sending Modem Init string...");
cputs_tr(_mdm_init_str);
delay_scr(20);
prints("Sending Auto-Answer string...");
cputs_tr(_auto_ans_str);
delay_scr(10);
}
finished_caller = kill_user = 0;
if (direct_connect)
carrier_counts = 0;
else {
carrier_counts = 1;
local_mode = 0;
prints("^M^JHost Mode: Waiting for call...");
prints("(Press Esc to exit, or 'L' for local test mode).^M^J");
do {
if (carrier()) break;
if ((c = inkey())==27) {
exit_requested = 1;
break;
}
else if (c==' ') { cputs("ata^m"); c=0; }
else if (toupper(c) == 'L') { // local test mode
prints("Local test mode entered");
local_mode = 1;
carrier_counts = 0;
break;
}
} while (1);
}
if (!exit_requested) {
prints("Incoming call. Sysop: press Esc to exit, or END to terminate user.");
do_one_caller();
if ((connection_lost || kill_user) && carrier_counts && carrier())
hangup(); // make sure nobody sneaks in
}
already_connected = 0;
if (exit_requested) {
if (!carrier() && !direct_connect) {
prints("Sending Modem Init string...");
cputs_tr(_mdm_init_str);
}
_scr_chk_key = old_scr_chk_key;
_cisb_auto = old_cisb_auto;
_zmod_auto = old_zmod_auto;
_sound_on = old_sound;
_down_dir = tfw_down_dir;
_up_dir = tfw_up_dir;
prints("^M^JHost mode script finished.");
usagelog("*CLOSE*");
_usage_fname = old_usage_fname;
return 1;
}
}
}
//////////////////////////////////////////////////////////////////////////////
host_help (str mode, str option) {
str fname[64];
fname = our_dir;
strcat (fname, mode);
strcat (fname, "_HELP_");
StrCat (fname, option);
StrCat (fname, ".TXT");
if (FileFind (fname, 0)) {
type_our_file (fname);
return (1);
}
else {
printsc ("^MCan't find help file ");
prints (fname);
return (0);
}
}
//////////////////////////////////////////////////////////////////////////////
do_one_caller() {
str strn[80], fname[64], s[80], temporary[1],
num[10], CHKSTR[20];
int option, status, c, i, i2, f, len, TIMR;
access_level = 1;
// flushbuf();
if (already_connected)
prints("Already conn